<template>
  <div style="width:300px;margin:auto auto;margin-top:300px;font-size:30px">
    成功支付{{money}}元!<br>
    订单编号为{{orderId}},<br>
    正在跳转订单页面，请稍等。。。。
  </div>
</template>
<script>
export default {
data(){
    return{
        orderId: this.$route.query.out_trade_no,
        money: this.$route.query.total_amount,
    }
},

  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.money=Math.floor(this.money);
      let params = new URLSearchParams();
      params.append('orderId', this.orderId);
      params.append('money',this.money)
      console.log(params);
      setTimeout(() => {
      if(this.orderId>100000){
        this.$axios.post("/order/charge",params)
        .then(res => {
          if (res.data.code == 200) {
            this.$router.push('/user/orderlies');
          } else {
            this.$router.push('/user/orderlies');
          }
        })
        .catch(error => {
          console.log(error);
        });
      }else{
        this.$axios.put("/order/paysuccess",params)
        .then(res => {
          if (res.data.code == 200) {
            this.$router.push('/user/orderlies');
          } else {
            alert('修改订单状态发生了错误');
            this.$router.push('/user/orderlies');
          }
        })
        .catch(error => {
          console.log(error);
        });
      }
      }, 5000);
    }
  }
};
</script>

<style scoped>
</style>